# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=xwiimote
pkgver=2_git20131227
pkgrel=0
_commit="f2be57e24fc24652308840cec2ed702b9d1138df"
pkgdesc="Open-source Nintendo Wii Remote Linux Device Driver"
url="https://github.com/dvdhrm/xwiimote"
# ppc64le fails to build
arch="all !ppc64le"
license="MIT"
makedepends="
	autoconf
	automake
	doxygen
	eudev-dev
	libtool
	linux-headers
	ncurses-dev
	"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc lib$pkgname:libs"
source="https://github.com/dvdhrm/xwiimote/archive/$_commit/xwiimote-$_commit.tar.gz
	0001-fix-32bit-build.patch
	xwiimote.conf
	"
builddir="$srcdir/$pkgname-$_commit"

prepare() {
	default_prepare

	NOCONFIGURE=1 ./autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

libs() {
	default_libs

	install -Dm644 -t "$subpkgdir"/usr/share/X11/xorg.conf.d "$builddir"/res/50-xorg-fix-xwiimote.conf
	install -Dm644 -t "$subpkgdir"/etc/modules-load.d "$srcdir"/xwiimote.conf
}

sha512sums="
f7bca448c81615225298bad786967f56579d2b93cb40063be9c4d37066891747f91d50e18e135ed932496f22ef4c8030ea206a7b7c4c3316e272afe764b0afce  xwiimote-f2be57e24fc24652308840cec2ed702b9d1138df.tar.gz
a47edd713725ac4b2327f37f4be4ae3717b8e1a715a4fb12bab0a4b8ffe0d64f7a4033f6176f07dd1776004564064f0373ae1ae2cfd1bd3f416ec2e41a7d9126  0001-fix-32bit-build.patch
ce1caa65cb231e9c2584bad8e7b8bb50ac3716ba6feb0d10a8fd271c401bc5a440c988b92f3321c5976a5ab5edf7ec8c5195d115f1c4c6ac9471f2a52a784e23  xwiimote.conf
"
